package com.jswdwsx.common.utils;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import java.io.StringReader;

public class XmlUtils {

    @SuppressWarnings("unchecked")
    public static <T> T unmarshal(String xml, Class<T> tClass) {
        try {
            return (T) JAXBContext.newInstance(tClass).createUnmarshaller().unmarshal(new StringReader(xml));
        } catch (JAXBException e) {
            e.printStackTrace();
        }
        return null;
    }

}
